<!--
	URL/edit2/:title
	app/views/resumes/edit2.html.erb 
	The edit2 resume view - edits (AJAXified) a particular resume of the user in full
	controller: resumes, action: edit2 
	
	Conventions used for this file - 
	1. part block id should be the controller name	
-->

<link rel="stylesheet" type="text/css" href="/stylesheets/resume_common.css" />
<link rel="stylesheet" type="text/css" href="/stylesheets/resumes/edit2.css" />

<span class="msg_baloon" style="background-color: red">Loading</span>

<div class="heading">
	<h3> Edit2 : <%=h @resume.title %>  </h3>
	<div class="links">
		<%= link_to 'Show', '/show/'+@resume.title %> 
		<%= link_to 'Print', '/show_p/'+@resume.title %> 
		<%= link_to 'Destroy', '/destroy/'+@resume.title, :confirm => 'Are you sure?', :method => :delete %>
	</div>	
</div>

<% url = '/update/'+@resume.title %>
<% form_tag(url, :method => "post") do %>

	<div class="parts_container" style="display: none">		<!-- display is none so that full 'naked' html is not visible while scripts load. Displayed later -->

		<div class="part" id="username">
			<div class="part_header">
				<h3>Name</h3> 
			</div>
			<div class="part_data">
				<div class="name">
					<span class="display"><%=h @resume.name %></span>
					<input 	type="text"
							class="edit"
							name="resume[name]"
							value="<%=h @resume.name %>" >
				</div>	
			</div>	
		</div>

		<div class="part" id="contacts">
			<div class="part_header">
				<h3>Contact</h3> 
			</div>
			<div class="part_data">
				<% if @resume.contact.nil? %>
					<%= link_to 'Add contact', '/new/'+@resume.title+'/contacts' %>
				<% else %>

					<b>Address - 	</b>
					<div class="address">
						<span class="display"><%=h @resume.contact.address %></span>
						<textarea
							class="edit"
							name="contact[address]" 
							><%=h @resume.contact.address %></textarea>
					</div>
					
					<b>Phone_nos -	</b>
					<div class="phone_nos">
						<span class="display"><%=h @resume.contact.phone_nos %></span>	
						<input	type="text"
							class="edit"
							name="contact[phone_nos]"
							value="<%=h @resume.contact.phone_nos %>" >
					</div>
					
					<b>Emails -		</b>
					<div class="emails">
						<span class="display"><%=h @resume.contact.emails %></span>
						<input	type="text"
							class="edit"
							name="contact[emails]"
							value="<%=h @resume.contact.emails %>" >
					</div>		
				<% end #if-else %>
			</div>	
		</div>

		<div class="part" id="profiles">
			<div class="part_header">
				<h3>Profile</h3> 
			</div>
			<div class="part_data">
				<% if @resume.profile.nil? %>
					<%= link_to 'Add profile', '/new/'+@resume.title+'/profiles' %>
				<% else %>
					<div class="profile_text">
						<span class="display"><%=h @resume.profile.profile_text %></span>
						<textarea 
							class="profile_text edit"
							name="profile[profile_text]"
							><%=h @resume.profile.profile_text %></textarea>
					</div>		
				<% end #if-else %>
			</div>	
		</div>

		<div class="part" id="skills">
			<div class="part_header">
				<h3>Skills</h3>
			</div>
			<div class="part_data">
				<% if @skills.size ==0 %>
					No skill data.
				<% else %>
					<table class="skills_table">	<!-- table meant only for headings -->
						<tr>
							<th class="skillset_type">  
							<th class="skill_name">skill_name
							<th class="skill_remarks">skill_remarks 
						</tr>	
					</table>	
					<% prev = nil %>
					<% @skills.each do |skill| %>

						<% isDiffSkillSet = (!prev or (skill.skillset_type!=prev.skillset_type)) %>
						<table id="skill_<%=h skill.id %>" class="skills_table deleteable">
						<tr class="<%=h isDiffSkillSet ? 'new_skillset' : 'repeat_skillset' %>">
							<td class="skillset_type">
								<span class="display <%=h isDiffSkillSet ? '' : 'hidden' %>"><%=h skill.skillset_type %></span>
								<input 	type="text"
										class="edit"
										name="skills[<%=h skill.id %>][skillset_type]"
										value="<%=h skill.skillset_type %>" >
							</td>
							<td class="skill_name">
								<span class="display"><%=h skill.skill_name %></span>
								<input	type="text"
										class="edit"
										name="skills[<%=h skill.id %>][skill_name]"
										value="<%=h skill.skill_name %>" >
							</td>
							<td class="skill_remarks">
								<span class="display"><%=h skill.skill_remarks %></span>
								<input	type="text"
										class="edit"
										name="skills[<%=h skill.id %>][skill_remarks]"
										value="<%=h skill.skill_remarks %>" >
							</td>
							<td class="delete_column"><span class="delete_button">x</span></td>
						</tr>
						</table>	<!-- one row per table. Introduced table to match formatting of experience and education -->
					<% prev = skill %>	
					<% end #loop %>
				<% end #if-else %>
				<div class="addMore">	
					<table class="skills_table addTable">
						<tr class="new_skillset">
							<td class="skillset_type">
								<span class="display hidden"></span>
								<input 	type="text"
										class="add"
										name="skills[skillset_type]">
							</td>
							<td class="skill_name">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="skills[skill_name]" >
							</td>
							<td class="skill_remarks">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="skills[skill_remarks]">
							</td>
							<td class="delete_column"><span class="delete_button hidden">x</span></td>
						</tr>
					</table>
					<span class="plusButton">+</span>
				</div>	
			</div>	<!-- part_data -->
		</div>

		<div class="part" id="educations">
			<div class="part_header">
				<h3>Education</h3>
			</div>	
			<div class="part_data">
				<% if @resume.educations.size ==0 %>
					<%# empty as of now %>
				<% else %>
					<% @resume.educations.each do |education| %>
					<table id="education_<%=h education.id %>" class="education_table deleteable">
					<tr>
						<td class="column1">Level</td>
						<td class="level">
							<span class="display"><%=h education.level %></span>
							<input	type="text"
									class="edit"
									name="education[<%=h education.id %>][level]"
									value="<%=h education.level %>" >
						</td>
						<td class="delete_column"><span class="delete_button">x</span></td>
					</tr>
					<tr>
						<td class="column1">Major</td>
						<td class="major">
							<span class="display"><%=h education.major %></span>
							<input	type="text"
									class="edit"
									name="education[<%=h education.id %>][major]"
									value="<%=h education.major %>" >
							</td>
					</tr>
					<tr>
						<td class="column1">College</td>
						<td class="college">
							<span class="display"><%=h education.college %></span>
							<input	type="text"
									class="edit"
									name="education[<%=h education.id %>][college]"
									value="<%=h education.college %>" >
						</td>
					</tr>
					<tr>
						<td class="column1">Score</td>
						<td class="score">
							<span class="display"><%=h education.score %></span>
							<input	type="text"
									class="edit"
									name="education[<%=h education.id %>][score]"
									value="<%=h education.score %>" >
						</td>
					</tr>	
					<tr>
						<td class="column1">More info</td>
						<td class="more_info">
							<span class="display"><%=h education.more_info %></span>
							<textarea
									class="edit"
									name="education[<%=h education.id %>][more_info]"
									><%=h education.more_info %></textarea>
						</td>
						
					</tr>
					</table>
					<% end #loop %>
				<% end #if-else %>
				<div class="addMore">
					<table class="education_table addTable">
						<tr>
							<td class="column1">Level</td>
							<td class="level">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="education[level]" >
							</td>
							<td class="delete_column"><span class="delete_button">x</span></td>
						</tr>
						<tr>
							<td class="column1">Major</td>
							<td class="major">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="education[major]" >
							</td>
						</tr>
						<tr>
							<td class="column1">College</td>
							<td class="college">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="education[college]">
							</td>
						</tr>
						<tr>
							<td class="column1">Score</td>
							<td class="score">
								<span class="display hidden"></span>
								<input	type="text"
										class="add"
										name="education[score]" >
							</td>
						</tr>	
						<tr>
							<td class="column1">More info</td>
							<td class="more_info">
								<span class="display hidden"></span>
								<textarea
										class="add"
										name="education[more_info]"></textarea>
							</td>
						</tr>					
					</table>
					<span class="plusButton">+</span>
				</div>
			</div> <!-- part_data -->	
		</div>

		<div class="part" id="experiences">
			<div class="part_header">
				<h3> Experience </h3>
			</div>	
			<div class="part_data">
				<% if @resume.experiences.size == 0 %>	
					No experience data.
				<% else %>
					<% @resume.experiences.each do |experience| %>
					<table id="experience_<%=h experience.id %>" class="experience_table deleteable">
					<tr>
						<td class="column1">Title</td>
						<td class="experience_title">
							<span class="display"><%=h experience.title %></span>
							<input	type="text"
									class="edit"
									name="experience[<%=h experience.id %>][title]"
									value="<%=h experience.title %>" >
						</td>
						<td class="delete_column"><span class="delete_button">x</span></td>						
					</tr>
					<tr>
						<td class="column1">Company</td>
						<td class="company">
							<span class="display"><%=h experience.company %></span>
							<input 	type="text"
									class="edit"
									name="experience[<%=h experience.id %>][company]"
									value="<%=h experience.company %>" >
						</td>
					</tr>
					<tr>
						<td class="column1">Duration</td>
						<td class="duration">
							<span class="display"><%=h experience.duration %></span>
							<input	type="text"
									class="edit"
									name="experience[<%=h experience.id %>][duration]"
									value="<%=h experience.duration %>" >
						</td>
					</tr>
					<tr>
						<td class="column1">Role</td>
						<td class="role">
							<span class="display"><%=h experience.role %></span>
							<textarea	
									class="edit"
									name="experience[<%=h experience.id %>][role]"
									><%=h experience.role %>" </textarea>
						</td>
					</tr>
					<tr>
						<td class="column1">More Info</td>
						<td class="more_info">
							<span class="display"><%=h experience.more_info %></span>
							<textarea
									class="edit"
									name="experience[<%=h experience.id %>][more_info]"
									><%=h experience.more_info %></textarea>
						</td>
					</tr>
					</table>	
					<% end #loop %>
				<% end %>
				<div class="addMore">
					<table class="experience_table addTable">
						<tr>
							<td class="column1">Title</td>
							<td class="experience-title">
								<span class="display hidden"></span>
								<input 	type="text" 
										class="add" 
										name="experience[title]">
							</td>
							<td class="delete_column"><span class="delete_button hidden">x</span></td>
						</tr>
						<tr>
							<td class="column1">Company</td>
							<td class="company">
								<span class="display hidden"></span>
								<input 	type="text" 
										class="add" 
										name="experience[company]">
							</td>
						</tr>
						<tr>
							<td class="column1">Duration</td>
							<td class="duration">
								<span class="display hidden"></span>
								<input 	type="text" 
										class="add" 
										name="experience[duration]">
							</td>
						</tr>
						<tr>
							<td class="column1">Role</td>
							<td class="role">
								<span class="display hidden"></span>
								<textarea 	class="add" 
											name="experience[role]"></textarea>
							</td>
						</tr>
						<tr>
							<td class="column1">More info</td>
							<td class="more_info">
								<span class="display hidden"></span>
								<textarea class="add" name="experience[more_info]"></textarea>
							</td>					
						</tr>
						</table>	
					<span class="plusButton">+</span>
				</div> <!-- add more -->
			</div> <!-- part_data -->	
		</div>

		<div class="part" id="achievements">
			<div class="part_header">
				<h3>Achievements</h3>
			</div>
			<div class="part_data">			
				<% if @resume.achievement.nil? %>
					<%= link_to 'Add Achievements', '/new/'+@resume.title+'/achievements' %>
				<% else %>	
					<div class="achievements_text">
						<span class="display"><%=h @resume.achievement.achievements_text %></span>
						<textarea
							class="edit"
							name="achievement[achievements_text]"
							><%=h @resume.achievement.achievements_text %></textarea>
					</div>
				<% end %>
			</div> <!-- part_data -->	
		</div>

		<div class="part" id="hobbies">
			<div class="part_header">
				<h3>Hobbies:</h3>
			</div>
			<div class="part_data">
				<% if @resume.hobby.nil? %>
					<%= link_to 'Add Hobbies', '/new/'+@resume.title+'/hobbies' %>
				<% else %>	
				<div class="hobbies_text">
					<span class="display"><%=h @resume.hobby.hobbies_text %></span>
					<textarea
							class="edit"
							name="hobby[hobbies_text]"
							><%=h @resume.hobby.hobbies_text %></textarea>
				</div>			
				<% end %>
			</div> <!-- part_data -->	
		</div>

	</div>	<!-- parts_container -->	

	<span class="button_stripe hidden">
		<span class="update">Update</span>
		<span class="clear">Clear</span>
	</span>
	
<% end %>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/javascripts/resume_common.js"></script>
<script type="text/javascript" src="/javascripts/resumes/edit2.js"></script>
